
from conn_mysql_redis import ConnRedis, ConnMysql, InsertConnMysql
import asyncio

class AccessToken():

    async def access_token_verify_func(self,access_token,user_id):

        if not all([access_token,user_id]):

            return {
                'status': -1,
                'errorCode': 41,
                'errorMsg': '参数不够,access_token为空',
                'resultBody': None,
            }

        with await ConnRedis().pool_ as c:

            info=await c.hvals(access_token,encoding="utf8")
            
        if not info:

            return {
                'status': -1,
                'errorCode': 42,
                'errorMsg': 'access_token已经过期请重新登录',
                'resultBody': None,
            }

        if info[0]!=user_id:

            return {
                'status': -1,
                'errorCode': 43,
                'errorMsg': 'access_token没有找到配对',
                'resultBody': None,
            }
          
        return {
            'status': 1,
            'errorCode': None,
            'errorMsg': None,
            'resultBody': '验证通过',
        }



        



            